/*
 * Serum
 *
 * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
 */

Ext.namespace('Serum');

/**
 * Serum main object
 */
Serum.App = function() {
    var _instance = null;

    var __construct = function() {
        return {
            /**
             * Event listener instance
             */
            eventListener: null,

            /**
             * Serum initialisation
             */
            init: function() {
                Ext.QuickTips.init();
                Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

                Serum.Selector.get().load();

                // Event listener
                _instance.eventListener  = new Serum.Event.Listener();

                // GUI
                new Serum.Panel.Main();

                // Loads module
                Serum.Selector.get().set({module: Serum.Selector.get().module}, false);
            }
        }
    };

    return {
        /**
         * Returns instance
         *
         * @return  {Serum.App}     Instance
         */
        get: function() {
            if (_instance === null) {
                _instance = __construct();
            }
            return _instance;
        }
    };
}();

Ext.onReady(function() {
    Serum.App.get().init();
});